package cn.com.zhangwoo.microstar.adapter;

import cn.com.microstar.activity.R;
import cn.com.zhangwoo.microstar.inteface.IUtilDB;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class SupermarketGridViewAdapter extends BaseAdapter {

	private Context context;
	private int[] array;
	private LayoutInflater inflater;
	TextView text;
	public SupermarketGridViewAdapter(Context context,int[] array) {
		// TODO Auto-generated constructor stub
		this.context=context;
		this.inflater=LayoutInflater.from(context);
		this.array=array;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return array.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return array[position];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@SuppressLint("ResourceAsColor") @Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView mImageView;
		if (null==convertView) {
			convertView=inflater.inflate(R.layout.item_gridview_supermatker, null);
			mImageView=(ImageView) convertView.findViewById(R.id.item_supermarket_gridviewImage);
			convertView.setTag(mImageView);
		}
		else
		{
			mImageView=(ImageView) convertView.getTag();
		}
		try {
			mImageView.setImageResource(IUtilDB.img[position]);
			//mImageLoader.get(listDataa[position], 
			//com.android.volley.toolbox.ImageLoader.getImageListener(mImageView,R.drawable.zhangwo_hometop2, R.drawable.zhangwo_hometop2));
		} catch (Exception e) {
			mImageView.setImageResource(IUtilDB._TOPHOMEPAGEIMG[0]);
		}
		return convertView;
	}
	


}
